package mynote;

import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusEvent;

//注册密码自动检查监听
public class PwdCheckListener extends PwdFocusListener {
    private SignUpDialog signUp;

    public PwdCheckListener(String tipText, JPasswordField pwdField, SignUpDialog signUp) {
        super(tipText, pwdField);
        this.signUp = signUp;
    }

    @Override
    public void focusLost(FocusEvent e) {
        if (String.valueOf(this.pwdField.getPassword()).equals("")) {
            this.pwdField.setText(tipText);
            this.pwdField.setEchoChar((char)0);
            this.pwdField.setForeground(Color.GRAY);
        }
        else {
            //检查密码是否符合条件
            signUp.CheckPwd();
        }
    }
}
